import scrapy
from  scrapy import  Selector,Request


class BzspiderSpider(scrapy.Spider):
    name = "BZspider"
    allowed_domains = ["netbian.com"]
    start_urls = ["http://www.netbian.com/weimei/"]

    def parse(self, response):
        t=response.text
        sel = Selector(response)
        li_tags = sel.xpath('//div[@id="main"]//li')
        for li in li_tags:
            title_list=li.xpath('./a/@title').extract()
            href_list=li.xpath('./a/@href').extract()
            if len(title_list) !=0:
                title=title_list[0]
                href=response.urljoin(href_list[0])
                print(title,href)
                yield Request(url=href, callback=self.parseImageDetail)


    def parseImageDetail(self,response):
        # http: // www.netbian.com / down.php?id = 31116 & type = undefined
        # http: // www.netbian.com / desk / 31116 - 1920x1080.htm
        pass